﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>$CreationDate$</CreationDate>
</File>
*/
#endregion

using System;
using System.Globalization;
#if NETFX_CORE
using Windows.UI.Xaml.Data;
#elif __ANDROID__
using Outcoder.UI.Xaml.Data;
using Outcoder.UI.Xaml.ValueConverters;
#else
using System.Windows.Data;
#endif

namespace Outcoder.UI.Xaml.Converters
{
	public class InvertedBooleanToVisibilityConverter : IValueConverter
	{
		readonly BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

#if !NETFX_CORE
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			bool? boolValue = null;
			if (value != null)
			{
				boolValue = !(bool)value;
			}
			
			return converter.Convert(boolValue, targetType, parameter, culture);
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			bool? boolValue = null;
			if (value != null)
			{
				boolValue = !(bool)value;
			}

			return converter.ConvertBack(boolValue, targetType, parameter, culture);
		}
#else
		public object Convert(object value, Type targetType, object parameter, string culture)
		{
			return !(bool)converter.Convert(value, targetType, parameter, culture);
		}

		public object ConvertBack(object value, Type targetType, object parameter, string culture)
		{
			return !(bool)converter.ConvertBack(value, targetType, parameter, culture);
		}
#endif
	}
}